import { createRouter, createWebHistory } from 'vue-router'

const routes = [
  {
    path: '/',
    name: 'Home',
    component: () => import('@/views/HomePage.vue'),
    children: [
      {
        path: '/create-work-order',
        name: 'CreateWorkOrder',
        component: () => import('@/views/CreateWorkOrder.vue'),
      },
      {
        path: '/ServiceOrderHandle',
        name: 'ServiceOrderHandle',
        component: () => import('@/views/ServiceOrderHandle.vue'),
      },
      // 新增子路由配置
      {
        path: '/appointment-time',
        name: 'AppointmentTime',
        component: () => import('@/views/AppointmentTime.vue'),
      },
      {
        path: '/work-order-followup',
        name: 'WorkOrderFollowup',
        component: () => import('@/views/WorkOrderFollowup.vue'),
      },
      {
        path: '/work-order-dispatch',
        name: 'WorkOrderDispatch',
        component: () => import('@/views/WorkOrderDispatch.vue'),
      },
      {
        path: '/repair-workorder-list',
        name: 'RepairWorkOrderList',
        component: () => import('@/views/RepairWorkOrderList.vue'),
      },
      {
        path: '/user-info-edit',
        name: 'UserInfoEdit',
        component: () => import('@/views/UserInfoEdit.vue'),
      },
      {
        path: '/permission-application',
        name: 'PermissionApplication',
        component: () => import('@/views/PermissionApplication.vue'),
      },
      {
        path: '/station-join-apply',
        name: 'StationJoinApply',
        component: () => import('@/views/StationJoinApply.vue'),
      },
      {
        path: '/application-list',
        name: 'ApplicationList',
        component: () => import('@/views/ApplicationList.vue'),
      },
      {
        path: '/admin-workorder-list',
        name: 'AdminWorkOrderList',
        component: () => import('@/views/AdminWorkOrderList.vue'),
      },
      {
        path: '/user-list',
        name: 'UserList',
        component: () => import('@/views/UserList.vue'),
        meta: { title: '用户列表' }, // 可选，用于面包屑或标签页标题
      },
      {
        path: '/:id',
        name: 'order-detail',
        component: () => import('@/views/OrderDetail.vue'),
      },
    ],
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/LoginPage.vue'),
  },
  {
    path: '/register',
    name: 'Register',
    component: () => import('@/views/RegisterPage.vue'),
  },
]

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes,
})

export default router
